<template>
  <div class="recommend-list">
    <div class="recommend-item" v-for="item in list" :key="item.id" @click="toDeailPage(item)" >
      <img :src="item.imageHost + item.mainImage" />
      <p>{{ item.name }}</p>
      <i>￥ {{item.price}}</i>
    </div>
  </div>
</template>

<script>
import { proRec } from "../api/index";
export default {
  data() {
    return {
      list: {},
    };
  },
 mounted() {
    proRec( (res)=>{
        // console.log(res.data.data);
        this.list = res.data.data;
    });
  },
  methods:{
    toDeailPage(item){
      // console.log(item);
      this.$router.push("/product/"+item.id)
    }
  }
};
</script>

<style lang="scss" scoped>
.recommend-list {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 30px;
  padding-bottom: 150px;
  box-sizing: border-box;
  background: #fff;

  .recommend-item {
    display: flex;
    flex-direction: column;
    width: 50%;
    padding: 20px;
    box-sizing: border-box;
    border-bottom: 1px solid #dcdcdc;

    &:nth-child(2n-1) {
      border-right: 1px solid #dcdcdc;
    }

    img {
      width: 100%;
      height: 290px;
      margin: 0 auto;
    }

    p {
      height: 60px;
      padding: 20px 0;
      font-size: 26px;
      line-height: 40px;
      color: #333;
      overflow: hidden;
    }

    i {
      font-style: normal;
      font-size: 32px;
      color: red;
    }
  }
}
</style>